package com.isdepci.project.carbon.service.impl;

import com.isdepci.common.constant.HttpStatus;
import com.isdepci.common.exception.CustomException;
import com.isdepci.common.utils.SecurityUtils;
import com.isdepci.project.carbon.domain.AProject;
import com.isdepci.project.carbon.mapper.AProjectMapper;
import com.isdepci.project.carbon.service.IAProjectService;
import com.isdepci.project.system.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 项目列Service业务层处理
 *
 * @author isdepci
 * @date 2025-03-29
 */
@Service
public class AProjectServiceImpl implements IAProjectService
{
    @Autowired
    private AProjectMapper aProjectMapper;


    @Override
    public List<AProject> selectProjectByUserId(Long userId) {
        return aProjectMapper.selectProjectByUserId(userId);
    }



    /**
     * 查询项目列
     */
    @Override
    public AProject selectAProjectById(Long projectId)
    {
        return aProjectMapper.selectAProjectById(projectId);
    }

    /**
     * 查询项目列列表
     */
    @Override
    public List<AProject> selectAProjectList(AProject aProject)
    {
        return aProjectMapper.selectAProjectList(aProject);
    }

    /**
     * 新增项目列
     */
    @Override
    public int insertAProject(AProject aProject)
    {
        SysUser user = SecurityUtils.getUser();
        if (user == null) {
            throw new CustomException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
        }
        aProject.setUserId(user.getUserId());
        aProject.setDeptId(user.getDeptId());
        return aProjectMapper.insertAProject(aProject);
    }

    /**
     * 修改项目列
     */
    @Override
    public int updateAProject(AProject aProject)
    {
        return aProjectMapper.updateAProject(aProject);
    }

    /**
     * 批量删除项目列
     */
    @Override
    public int deleteAProjectByIds(Long[] projectIds)
    {
        return aProjectMapper.deleteAProjectByIds(projectIds);
    }

    /**
     * 删除项目列信息
     */
    @Override
    public int deleteAProjectById(Long projectId)
    {
        return aProjectMapper.deleteAProjectById(projectId);
    }
}
